02. Practice: Apply What You've Learned

Practice with Dave

Next, Dave will ask you to write a function that adds the letter U to the beginning of strings. This is just meant to give you another chance at defining a function with the proper syntax. Some things to keep in mind:

On the first line of your function definition…

  • You must begin the line with def (lowercase).
  • After def you must give a function name (in this case it will be udacify).
  • Next, you must have a set of parentheses with the required parameters inside.
  • The line must end with a : colon.

In the body of the function

  • Every line in the function must be indented.
  • If you want your function to produce output, it must end with a return statement.

To "call" the function…

"Calling" a function just means using it. You do this by writing:

  1. The function name, followed by…
  2. …an open paren (, followed by…
  3. …the values for the required parameters, followed by…
  4. …a closed paren ).

To display the results of a function call.

Don't forget to include the print command before you call your function if you want to display the result on your screen!